<input type="text">
<button>send</button>
<textarea name="" id="" cols="30" rows="10" disabled></textarea>
<script>
  const ws = new WebSocket('ws://localhost:3000');
  ws.addEventListener('open', function () {
  })
  ws.addEventListener('message', function (e) {
    document.querySelector('textarea').value = e.data
  })
</script>
<script>
  document.querySelector('button').addEventListener('click', function () {
    ws.send(document.querySelector('input').value)
  })
</script>